package shuati.tengxun;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author : LdLtd
 * @Date : 2023/11/16
 * @Description:云智开发客户端1
 * 找到两个数组中的子数组，使得它们的和的差值最接近
 */
public class yunzhike1 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int [] ar=new int[n];
        for (int i = 0; i < n; i++) {
            ar[i]=sc.nextInt();
        }
        int [] br=new int[m];
        for (int i = 0; i < m; i++) {
            br[i]=sc.nextInt();
        }
        int diff=Integer.MAX_VALUE;
        int l=0;
        int r=0;
        int sum = Arrays.stream(ar).sum();
        for (int i = 0; i <m; i++) {
            int curr=0;
            for (int j = i; j < m; j++) {
                curr+=br[j];
                if(Math.abs(curr-sum)<Math.abs(diff-sum)){
                    diff=curr;
                    l=i;
                    r=j;
                }
            }
        }
        for (int i = l; i <=r ; i++) {
            System.out.print(br[i]+" ");
        }
    }

}
